var connect = require('gulp-connect');
var proxy = require('http-proxy-middleware');
var gulp = require('gulp');
var less = require('gulp-less');
var lessDir = './src/less/**/**.less',
  cssDir = './src/css';


gulp.task('connect', function () {
  connect.server({
    root: './src',
    port: 8000,
    livereload: true,
    middleware: function (connect, opt) {
      return [
        proxy('/app', {
          target: 'http://47.92.140.159:80',
          changeOrigin: true
        })
      ]
    }
  });
})

gulp.task('less',function () {
  gulp.watch(lessDir, function () {
     gulp.src(lessDir)
      .pipe(less())
      .pipe(gulp.dest(cssDir))
  })
})
gulp.task('default',['connect','less']);